package goleetcode

import "strconv"

func findTheArrayConcVal(nums []int) int64 {
	i, j := 0, len(nums) - 1
	res := 0
	for i <= j {
		if i != j {
			res += Concatenated(nums[i], nums[j])
		} else {
			res += nums[i]
		}
		i++
		j--
	}
	return int64(res)
}

func Concatenated(i, j int) int {
	var res string
	res = strconv.Itoa(i) + strconv.Itoa(j)
	num, _ := strconv.Atoi(res)
	return num
}